home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Gooey1.3.1 / C Templates / mmMenu.c < prev    next >
Text File  |  1993-12-27  |  6KB  |  222 lines

  1. $$Message MM Menu, mm:mmMenu$Prototype.name$.h
  2. $$File mm:mmMenu$Prototype.name$.h
  3. /*  $CopyRight$ */
  4. /*  mmMenu$Prototype.name$                Handle menus
  5.  
  6.     File name:  mmMenu$Prototype.name$.h  
  7.     Function:  This contains the routines to handle menus.
  8.     History: $Date$ Original by $Author$
  9.  
  10.    */
  11.  
  12. /* ======================================================= */
  13. /* ======================================================= */
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. /* Initialize the menubar */
  20. void Init_My_Menus(void);
  21.  
  22. /* Handle the menu selection */
  23. void Handle_My_Menu( short theMenu,short theItem);
  24.  
  25. #ifdef __cplusplus
  26. }
  27. #endif
  28.  
  29. /* ======================================================= */
  30. /* ======================================================= */
  31. $$CloseFile
  32. $$Message MM Menu, mm:mmMenu$Prototype.name$.c
  33. $$File mm:mmMenu$Prototype.name$.c
  34. /*  $CopyRight$ */
  35. /*  mmMenu$Prototype.name$                Handle menus
  36.  
  37.     File name:  mmMenu$Prototype.name$.c  
  38.     Function:  This contains the routines to handle menus.
  39.     History: $Date$ Original by $Author$
  40.  
  41.    */
  42.  
  43. #include "mmCommon$Prototype.name$.h"    /* Common */
  44. #include "Common$Prototype.name$.h"        /* Common */
  45.  
  46. #include "mmMenu$Prototype.name$.h"        /* This file */
  47. #include "menu$Prototype.name$.h"
  48.  
  49. $$Loop Menus
  50. static void DoMenu$Menu.name$(short theItem);                    /* Handle this menu list, $Menu.FullName$ */
  51. $$EndLoop Menus
  52. $$Loop HierMenus
  53. static void DoMenu$Menu.name$(short theItem);                    /* Handle this menu list, $Menu.FullName$ */
  54. $$EndLoop HierMenus
  55.  
  56. /* ======================================================= */
  57. /* ======================================================= */
  58.  
  59. /* Routine: Init_My_Menus */
  60. /* Purpose: Load in the menu lists and initialize the menubar */
  61.  
  62. void Init_My_Menus(void)
  63. {
  64.  
  65. ClearMenuBar();                                    /* Clear any old menu bars */
  66.  
  67. $$Loop Menus
  68. /* This menu is  $Menu.FullName$ */
  69. Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$);                /* Get the menu from the resource file */
  70. InsertMenu(Menu_$Menu.name$,0);                            /* Insert this menu into the menu bar */
  71. $$if Menu.Apple
  72. AddResMenu(Menu_$Menu.name$,'DRVR');                        /* Add in DAs */
  73. $$endif
  74. $$if Menu.File
  75. $$endif
  76. $$if Menu.Edit
  77. $$endif
  78.  
  79. $$EndLoop Menus
  80. $$Loop HierMenus
  81. /* This menu is  $Menu.FullName$ */
  82. Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$);                /* Get the menu from the resource file */
  83. InsertMenu(Menu_$Menu.name$,-1);                            /* Insert this menu into the menu bar */
  84.  
  85. $$EndLoop HierMenus
  86.  
  87. AddExtraMenus();                                    /* Add any extra menu lists */
  88.  
  89. DrawMenuBar();                                        /* Draw the menu bar */
  90. }
  91.  
  92. /* ======================================================= */
  93.  
  94. $$Loop Menus
  95. /* Routine: DoMenu$Menu.name$ */
  96. /* Purpose: Handle all menu items in this list */
  97.  
  98. static void DoMenu$Menu.name$(short theItem)
  99. {
  100. Boolean        SkipProcessing;                        /* TRUE says skip processing */
  101. $$if Menu.Apple
  102. short        DNA;                                /* For opening DAs */
  103. Str255        DAName;                                /* For getting DA name */
  104. GrafPtr        SavePort;                            /* Save current port when opening DAs */
  105. $$endif
  106. $$if Menu.Edit
  107. Boolean        BoolHolder;                            /* For SystemEdit result */
  108. $$endif
  109.  
  110.  
  111. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  112.  
  113. Do_$Menu.name$Menu(true,theItem,&SkipProcessing);    /* Pre menu handler  */
  114.  
  115. if (SkipProcessing == false)                    /* See if process the menu list */
  116.     {
  117.     $$if Menu.Edit
  118.    BoolHolder = SystemEdit(theItem - 1);        /* Let the DA do the edit to itself */
  119.  
  120.     if (!BoolHolder)                            /* If not a DA then we get it */
  121.     {
  122.  
  123.     $$endif
  124.     switch (theItem)                            /* Handle all commands in this menu list */
  125.         {
  126.         $$Loop MenuItems
  127.         case MItem_$MenuItem.name$:                    /* For item $MenuItem.FullName$ */
  128.             $$Link    Menu
  129.             $$if Menu.Quit
  130.             doneFlag = true;                    /* Quit */
  131.             $$endif
  132.             break;
  133.         $$EndLoop MenuItems
  134.         default:                                /* allow other buttons, trap for debug */
  135.             $$if Menu.Apple
  136.             GetPort(&SavePort);                    /* Save the current port */
  137.             GetItem(Menu_$Menu.name$,theItem, DAName);    /* Get the name of the DA selected */
  138.             DNA = OpenDeskAcc(DAName);            /*Open the DA selected */
  139.             SetPort(SavePort);                    /* Restore to the saved port */
  140.             $$endif
  141.             break;                                /* end of otherwise */
  142.         }                                        /* end of switch */
  143.     $$if Menu.Edit
  144.     }
  145.     $$endif
  146.     }
  147.  
  148. Do_$Menu.name$Menu(false,theItem,&SkipProcessing);        /* Post menu handler  */
  149. }
  150.  
  151. /* ======================================================= */
  152.  
  153. $$EndLoop Menus
  154. $$Loop HierMenus
  155. /* Routine: DoMenu$Menu.name$ */
  156. /* Purpose: Handle all menu items in this list */
  157.  
  158. static void DoMenu$Menu.name$(short theItem)
  159. {
  160. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  161.  
  162.  
  163. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  164.  
  165. Do_$Menu.name$Menu(true,theItem,&SkipProcessing);            /* Pre menu handler  */
  166.  
  167. if (SkipProcessing == false)                        /* See if process the menu list */
  168.     {
  169.     switch (theItem)                                /* Handle all commands in this menu list */
  170.         {
  171.         $$Loop MenuItems
  172.         case MItem_$MenuItem.name$:                    /* For item $MenuItem.FullName$ */
  173.             $$Link    Menu
  174.             break;
  175.         $$EndLoop MenuItems
  176.         default:                                /* allow other buttons, trap for debug */
  177.             break;                                /* end of otherwise */
  178.         }                                        /* end of switch */
  179.     }
  180.  
  181. Do_$Menu.name$Menu(false,theItem,&SkipProcessing);        /* Post menu handler  */
  182. }
  183.  
  184. /* ======================================================= */
  185.  
  186. $$EndLoop HierMenus
  187. /* ======================================================= */
  188.  
  189. /* Routine: Handle_My_Menu */
  190. /* Purpose: Vector off to the appropiate menu list handler */
  191.  
  192. void Handle_My_Menu(short theMenu,short theItem)
  193. {
  194.  
  195.  
  196. switch (theMenu)                                    /* Do selected menu list */
  197.     {
  198.     $$Loop Menus
  199.     case Res_Menu_$Menu.name$:
  200.         DoMenu$Menu.name$(theItem);                    /* Go handle this list, $Menu.FullName$ */
  201.         break;
  202.     $$EndLoop Menus
  203.     $$Loop HierMenus
  204.     case Res_Menu_$Menu.name$:
  205.         DoMenu$Menu.name$(theItem);                    /* Go handle this list, $Menu.FullName$ */
  206.         break;
  207.     $$EndLoop HierMenus
  208.  
  209.     default:                                        /* allow other buttons, trap for debug */
  210.         Handle_Other_Menus(theMenu,theItem);        /* Handle other special menus */
  211.         break;                                        /* end of otherwise */
  212.     }                                                /* end of switch */
  213.  
  214. HiliteMenu(0);                                        /* Turn menu selection off */
  215. }
  216.  
  217. /* ======================================================= */
  218. /* ======================================================= */
  219. $$CloseFile
  220.  
  221.  
  222.